package com.jonluo.exception;


import com.jonluo.utils.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 *
 * @author jonluo
 * Date 2017/9/15
 * 异常处理器
 */
@RestControllerAdvice
public class RReturnExceptionHandler {
	private Logger logger = LoggerFactory.getLogger(getClass());

	/**
	 * 自定义异常
	 */
	@ExceptionHandler(RReturnException.class)
	public R handleRRException(RReturnException e){
		logger.error(e.getMessage(), e);
		return  R.error(e.getCode(),e.getMessage());
	}

	@ExceptionHandler(Exception.class)
	public R handleException(Exception e){
		logger.error(e.getMessage(), e);
		return  R.error(500,e.getMessage());
	}
}
